package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	file, err := os.Open("./test.txt")
	defer file.Close() // 延迟调用，关闭文件句柄
	if err != nil {
		fmt.Println(err)
	}
	reader := bufio.NewReader(file)

	for {
		line, err := reader.ReadString('\n') // 注意这里是字符
		if err == io.EOF {
			fmt.Fprintf(os.Stdout, "%s", line)
			break
		}
		fmt.Print(line)
	}
}
